<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Tagged
 *
 * @property int $id
 * @property int $tag_id 标签
 * @property string $module_type 模型
 * @property int $module_id 模型id
 * @property bool|null $is_robot 是否自动标签
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $module
 * @property-read \App\Models\Tag $tag
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereIsRobot($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereModuleId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereModuleType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereTagId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Tagged whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Tagged extends Model
{
    protected $fillable = ['tag_id','is_robot'];
    protected $casts    = ['is_robot' => 'boolean'];

    public function tag()
    {
        return $this->belongsTo(Tag::class);
    }

    public function module()
    {
        return $this->morphTo();
    }
}
